﻿@using KRM.Core
@model IEnumerable<VRefundRequest>
@{
    ViewBag.Title = "Refund Requests";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div style="padding: 10px">
    <form class="margin0" method="GET" id="frm-refund">
        <div class="row-fluid">
            <div class="span3">
                <label>
                    Request Type
                <select name="RequestType">
                    <option selected="selected" value="All">All</option>
                    <option value="Full Refund" @(Request["RequestType"] != null ? Request["RequestType"] == "Full Refund" ? "selected=selected" : "" : "")>Full Refund</option>
                    <option value="Partial Refund" @(Request["RequestType"] != null ? Request["RequestType"] == "Partial Refund" ? "selected=selected" : "" : "")>Partial Refund</option>
                </select>
                </label>

            </div>
            <div class="span3">
                <label>Request Status @Html.DropDownList("RefundRequestStatusID") </label>
            </div>
            <div class="span3">
                <label>
                    Order Ref
                    <input type="text" name="OrderRef" value="" />
                </label>
            </div>
            <div class="span3" style="">
                <br />
                <input type="submit" value="Search" class="btn btn-primary" />
            </div>
        </div>
    </form>
    <table class="table table-bordered table-fix krmtable" data-height="500">
        <thead class="thead">
            <tr>
                <th>Action</th>
                <th>OrderRef</th>
                <th>OrderValue</th>
                <th>RefundAmount</th>
                <th>RequestDate</th>
                <th>RequestType</th>
                <th>RequestBy</th>
                <th>Status</th>
                <th>Despatched</th>
                <th>IsDD</th>
                <th>OrderID</th>
                <th>StatusID</th>
                <th>RequestID</th>
            </tr>
        </thead>
        <tbody class="tbody">
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        <div class="btn-group">
                            <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><span class="caret"></span></a>
                            <ul class="dropdown-menu dropdowm-right">
                                <li>
                                    <a href="/orderView/orderdetail?orderref=@item.OrderRef" target="_blank" >View Order
                                    </a>
                                </li>
                                <li>
                                    <a href="javascript:;" onclick="PopupCenter('/orderview/viewrefundrequest/@item.RefundRequestID', 1100, 670);" >View Detail
                                    </a>
                                </li>
                                @if (item.RefundRequestStatusID == 2)
                                {
                                    <li>
                                        <a href="javascript:;" onclick="ChangePendingRefund(@item.RefundRequestID)">Change to Pending Refund</a>
                                    </li>
                                }
                                @if (item.RefundRequestStatusID == 1)
                                {
                                    <li>
                                        <a href="javascript:;" onclick="ChangeAwaitingCollectionToPendingRefund(@item.RefundRequestID)">Change to Pending Refund</a>
                                    </li>
                                }
                            </ul>
                        </div>
                    </td>
                    <td>@item.OrderRef</td>
                    <td>@item.OrderValue</td>
                    <td>@item.RefundAmount</td>
                    <td>@(((DateTime)item.RequestDate).ToString("dd/MM/yyy"))</td>
                    <td>@item.RequestType</td>
                    <td>@item.RequestBy</td>
                    <td>@item.Statuss</td>
                    <td>@item.Despatched</td>
                    <td>@item.IsDD</td>
                    <td>@item.OrderID</td>
                    <td>@item.RefundRequestStatusID</td>
                    <td>@item.RefundRequestID</td>
                </tr>
            }
        </tbody>
    </table>
</div>
